import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:enterprise_v8/app/components/custom_refresh.dart';
import 'package:enterprise_v8/app/components/toast_widget.dart';

import 'message_control.dart';

/// 消息页面 (产品原型测试页面,暂时不做正式开发)
class MessagePage extends StatelessWidget {
  const MessagePage({super.key});

  @override
  Widget build(BuildContext context) {
    final control = Get.put(MessageControl());
    return SafeArea(
      child: DefaultTabController(
        length: 2,
        child: Scaffold(
          body: Column(
            children: [
              Container(
                height: 50,
                color: Colors.white,
                child: const TabBar(
                  tabs: [
                    Tab(text: '报警信息'),
                    Tab(text: '通知'),
                  ],
                ),
              ),
              Expanded(
                child: TabBarView(
                  children: [
                    Container(
                      child: ListView.separated(
                        itemBuilder: (context, index) {
                          return ListTile(
                            leading: const Icon(Icons.warning, color: Colors.red),
                            title: Text('报警信息$index'),
                            subtitle: Text(DateTime.now().toString()),
                            trailing: Icon(Icons.arrow_forward_ios, size: 16, color: Colors.grey[500]),
                            onTap: () {
                              // 跳转到报警信息详情
                              // Get.toNamed(AppRoutes.personalPermission);
                              AppToast.showWarning('暂无权限查看通知详情');
                            },
                          );
                        },
                        separatorBuilder: (context, index) {
                          return const Divider();
                        },
                        itemCount: 20,
                      ),
                    ),
                    Container(
                        child: CustomEasyRefreshList<String>(
                      searchHint: '请输入姓名',
                      dataLoad: control.getListData,
                      separated: const Divider(),
                      itemBuilder: (item, index) {
                        return ListTile(
                          leading: const Icon(Icons.notifications, color: Colors.blue),
                          title: Text('通知信息$index'),
                          subtitle: Text(DateTime.now().toString()),
                          trailing: Icon(Icons.arrow_forward_ios, size: 16, color: Colors.grey[500]),
                          onTap: () {
                            // 跳转到通知信息详情
                            // Get.toNamed(AppRoutes.personalPermission);

                          },
                        );
                      },
                    )),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
